﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace OA.aspx.Main{ 
 public partial class InsertQianMing: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (tbSignData.Text.Trim() != "")
        {
            DrawSign(tbSignData.Text);
        }
        else
        {
            FTD.Unit.MessageBox.Show(this, "未发现任何签名数据！");
        }
    }
    private void DrawSign(string signdata)
    {
        System.Drawing.Bitmap image = new System.Drawing.Bitmap(400, 300);
        Graphics g = Graphics.FromImage(image);
         
        try
        {
           
            string TempStr = DateTime.Now.Ticks.ToString();
            image.Save(Server.MapPath("../../UploadFile/") + "Sign" + signdata + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            //返回图片值
           // Response.Write("<script language=javascript>window.returnValue =\"Sign" + signdata + ".jpg\";window.close();</script>");
                var imgidstr = Request["imgidstr"];
                Response.Write("<script language=javascript>sendFromChild();     function sendFromChild() {if (window.showModalDialog != undefined){window.returnValue ==\"Sign" + signdata + ".jpg\";window.close();}else{window.opener.callbackqianming(\"Sign" + signdata + ".jpg\",'" + imgidstr + "');window.close()}  }</script>");

                //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                ////Bmp最清晰.
                //image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                //Response.ClearContent();
                //Response.ContentType = "image/Jpeg";
                //Response.BinaryWrite(ms.ToArray());
            }
            catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine(e.Message);
        }
        finally
        {
            g.Dispose();
            image.Dispose();
        }
    }
}
}